package com.itheima.tlias.config;

import com.itheima.tlias.filter.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
    //注入拦截器
    @Autowired
    private TokenInterceptor tokenInterceptor;
    @Override
    public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry) {
        //添加拦截器
        registry.addInterceptor(tokenInterceptor)
                //拦截所有请求
                .addPathPatterns("/**")
                //放行请求
                .excludePathPatterns("/login","/css/**","/js/**","/images/**","/fonts/**","/layui/**","/favicon.ico");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
